package com.yunhe.history.client.fallback;

import com.yunhe.history.client.DeviceClient;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.device.Analog;
import com.yunhe.common.util.FallbackUtil;
import feign.hystrix.FallbackFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author liuronglei
 */
@Component
public class DeviceFallbackFactory implements FallbackFactory<DeviceClient> {
    @Override
    public DeviceClient create(Throwable arg0) {
        return new DeviceClient() {
            @Override
            public ResponseEntity<ResultObject<Analog>> getAnalogByDevAndType(Long deviceId, Long typeId, String typeName) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<List<Analog>>> getAnalogsByDevAndType(Long deviceId, Long typeId, String typeName) {
                return FallbackUtil.getDefaultFallBack();
            }
        };
    }
}
